﻿<%@ Page Language="c#" AutoEventWireup="False" Inherits="ElencySolutions.MultipleProperty.Edit.MultiplePropertyCopyProperty" %>
<%@ Import Namespace="ElencySolutions.MultipleProperty" %>
<%@ Register TagPrefix="EPiServerUI" Assembly="EPiServer" Namespace="EPiServer.Web.WebControls" %>
<%@ Register TagPrefix="EPiServerUI" Assembly="EPiServer.UI" Namespace="EPiServer.UI.WebControls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContentRegion" runat="server">
    <base target="_self" />
    <script type="text/javascript" src='<%= EPiServer.Shell.Paths.ToShellResource("ClientResources/EPiJQuery.js") %>'></script>
    <style type="text/css">
        .mpcp-container {display:block;padding: 10px 0 10px 10px;}
        .mpcp-InputsTable {margin-top:5px;margin-bottom:15px;}
        .mpcp-ButtonsRow {text-align:right;margin-top:8px;padding-top:8px}
        .mpcp-InputPageReference {float:left}
        .mpcp-EditColumn1 {width:200px;padding-left:9px}
        .mpcp-Clear {float:left;clear:both}
        .mpcp-errorPanel {clear:both;margin-top:10px}
        .mpcp-errorPanel a {text-decoration:underline!important}
        .mpcp-heading {font-weight:bold}
        .mpcp-hide {display:none}
        .mpcp-informationRow {clear:both;float:left;margin-bottom:10px}
        .mpcp-informationColumn1 {float:left;width:auto}
        .mpcp-informationColumn2 {float:left;margin-left:25px}
        .mpcp-Information {color:Red}
        .mpcp-LastButton {margin-right:25px}
        @-moz-document url-prefix() { .mpcp-InputPageReference .epismallbutton {width:23px} }
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FullRegion" runat="server">
    <EPiServerUI:BodySettings CssClass="epi-applicationSidebar" runat="server" />

    <div class="mpcp-container">
        <p class="mpcp-heading"><%=Translate("copyProperty")%></p>
    
        <div class="mpcp-informationRow">
            <div class="mpcp-informationColumn1">
                <strong><%=Translate("pageName")%></strong>: <asp:Literal ID="PageNameLiteral" runat="server" />
            </div>
            <div class="mpcp-informationColumn2">
                <strong><%=Translate("propertyName")%></strong>: <asp:Literal ID="PropertyNameLiteral" runat="server" />
            </div>
        </div>

        <asp:Panel runat="server" ID="panMessage" CssClass="EP-systemMessage mpcp-Clear" Visible="false">
            <table cellspacing="5">
	            <tr>
		            <td><asp:Literal ID="litMessage" EnableViewState="false" runat="server"></asp:Literal></td>
	            </tr>
            </table>
        </asp:Panel>

        <asp:PlaceHolder ID="FormPlaceHolder" runat="server">
            <table class="mpcp-InputsTable mpcp-errorPanel">
                <tr>
                    <td class="mpcp-EditColumn1">
                        <%=Translate("copyTo")%>
                    </td>
                    <td>
                        <div class="mpcp-InputPageReference">
                            <EPiServerUI:InputPageReference ID="CopyToPageLinkUrl" runat="server" DisableCurrentPageOption="true" />
                        </div>
                        <asp:RequiredFieldValidator EnableClientScript="false" Text="*" runat="server" ControlToValidate="CopyToPageLinkUrl" ErrorMessage='<%#Translate("youMustSelectAPageToCopyTo")%>' />
                    </td>
                </tr>
                <asp:PlaceHolder ID="PropertiesPlaceHolder" runat="server" Visible="false">
                    <tr>
                        <td class="mpcp-EditColumn1">
                            <%=Translate("propertyToReplace")%>
                        </td>
                        <td>
                            <asp:DropDownList ID="PropertyToReplaceDropDownList" runat="server" />
                            <asp:RequiredFieldValidator EnableClientScript="false" Text="*" runat="server" ControlToValidate="PropertyToReplaceDropDownList" ErrorMessage='<%#Translate("youMustSelectAPropertyToOverwrite")%>' InitialValue="-1" />
                        </td>
                    </tr>
                </asp:PlaceHolder>
                <tr>
                    <td class="mpcp-ButtonsRow" colspan="2">
                        <EPiServerUI:ToolButton ID="CopyButton" Enabled="true" CommandName="Copy" SkinID="Copy" ToolTip='<%#Translate("copy")%>' Text='<%#Translate("copy")%>' runat="server" OnClick="CopyButtonClick" CausesValidation="true" />
                        <span class="mpcp-LastButton">
                            <EPiServerUI:ToolButton ID="CancelButton" Enabled="true" CommandName="Cancel" SkinID="Cancel" ToolTip='<%#Translate("cancel")%>' Text='<%#Translate("cancel")%>' runat="server" OnClientClick="javascript:window.close();" CausesValidation="false" />    
                        </span>
                    </td>
                </tr>
            </table>
            <asp:Button ID="PageChangedButton" runat="server" CssClass="mpcp-hide" OnClick="PageChangedButtonClick" CausesValidation="false" />
        </asp:PlaceHolder>

        <script type="text/javascript">
            if ($('#<%=CopyToPageLinkUrl.ValueControl.ClientID%>').length > 0) {
                var copyToPageValue = $('#<%=CopyToPageLinkUrl.ValueControl.ClientID%>').val();
                var intervalId = setInterval("HasPageChanged()", 50);
            }

            function HasPageChanged() {
                var currentValue = $('#<%=CopyToPageLinkUrl.ValueControl.ClientID%>').val();

                if (currentValue == copyToPageValue)
                    return;

                clearInterval(intervalId);
                $('#<%=PageChangedButton.ClientID%>').click();
            }
        </script>
    </div>

</asp:Content>